package jd;

import javax.sound.midi.Soundbank;
import java.util.Scanner;
import java.util.concurrent.ForkJoinPool;

public class gunqiu {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int array[][] = new int[n][2*n-1];
        for (int i = 0; i < n; i++) {
            for (int j = n-i-1; j < n+i ; j++) {
                array[i][j] = scan.nextInt();
            }
        }
        int dp[][] = new int[n][2*n-1];
        for (int j = 0; j <2*n-1; j++) {
            dp[n-1][j] = array[n-1][j];
        }
        int result = 0;
        for (int i = n-2; i >= 0; i--) {
            for (int j = n-i-1; j <n+i; j++) {
                int max = Math.max(dp[i+1][j],dp[i+1][j+1]);
                dp[i][j] = Math.max(dp[i+1][j-1],max) + array[i][j];
                result = dp[i][j];
            }
        }
        System.out.println(result);
    }
}
